#!/bin/bash

# Get current application identifier
APPID=$(osascript -e "set appid to id of application (path to frontmost application as Unicode text)")

# Leave if empty
[ -z "$APPID" ] && exit 0

# Ask user confirmation
CONFIRM=$(osascript -e "display dialog \"Remove Preferences of $APPID ?\" buttons {"yes", "no"}" -e "set rep to button returned of the result")
CONFIRM=${CONFIRM:0:1}
[ "$CONFIRM" != "y" ] && exit 0

# Remove prefs
defaults delete $APPID
